package com.hsy.linemoney.modules.my.status_and_record;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.widget.ListView;

import com.deparse.dpframe.tools.utils.DPUnitUtil;
import com.hsy.linemoney.R;
import com.hsy.linemoney.apiservice.Callback;
import com.hsy.linemoney.apiservice.MyDealService;
import com.hsy.linemoney.modules.common.CommonBaseActivityWithSimpleActionBar;

import java.util.ArrayList;
import java.util.List;

/**
 * 交付状态与记录
 * Created by MartinKent on 2016/10/24.
 */

public class MyStatusAndRecordActivity extends CommonBaseActivityWithSimpleActionBar {
    private ListView listView;
    protected MyStatusAndRecordListAdapter adapter;
    private List<MyStatusAndRecordBean> data = new ArrayList<>();

    private MyDealService service = new MyDealService();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle(R.string.txt_status_and_record);
        listView = new ListView(this);
        setContentView(listView);

        listView.setDivider(new ColorDrawable(Color.parseColor("#f8f8f8")));
        listView.setDividerHeight(DPUnitUtil.dip2px(this,15));
        listView.setSelector(new ColorDrawable(Color.TRANSPARENT));

        adapter = new MyStatusAndRecordListAdapter(this);
        listView.setAdapter(adapter);

//        for (int i = 0; i < 30; i++) {
//            data.add(new MyStatusAndRecordBean());
//        }
//        adapter.update(data);

        service.getCompletedOrders(new Callback<MyDealService.CompletedOrdersResult>() {
            @Override
            public void onSuccess(int what, MyDealService.CompletedOrdersResult result) {
                if(null != result.getData().getCompletedOrders()){
                    adapter.update(result.getData().getCompletedOrders());
                }
            }

            @Override
            public void onError(int what, int type, String msg, Exception e) {

            }
        });
    }
}
